home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Libraries / VideoToolbox 94.11.17 / VideoToolboxSources / VideoToolbox.h < prev    next >
Encoding:
Text File  |  1994-11-17  |  40.2 KB  |  1,146 lines  |  [TEXT/KAHL]

  1. /*
  2. VideoToolbox.h
  3. This file contains the necessary prototypes for use of all the VideoToolbox
  4. files except Luminance.c, which has its own header file, Luminance.h, and
  5. GDInfo.c and GDTestClut.c, which use GDInfo.h.
  6.  
  7. Precompilation of this header, producing either VideoToolbox.pre or
  8. VideoToolboxMATLAB.pre, will reduce your compilation time tenfold. See
  9. VideoToolbox.c or VideoToolboxMATLAB.c for instructions.
  10.  
  11. Header files whose precompilation depends on the mc68881 or mc68020 THINK C
  12. compiler options (i.e. math.h and mc68881.h) were omitted from VideoToolbox.h so
  13. that the resulting precompiled header file can be used in projects regardless of
  14. those options. (You’ll want them enabled for speed in your lab, but you’ll
  15. usually want them disabled for portability on the road, e.g. the PowerBook 160
  16. has no floating point unit.) If you change other options that affect the
  17. pre-compilation of the headers (e.g. size of double or size of int) you should
  18. rebuild the precompiled header file, to reflect the new settings.
  19.  
  20. However, the precompilation _does_ depend on the sizeof(double) and sizeof(int)
  21. because most functions use or return such values and the external interface must
  22. allow the appropriate amount of space. THINK C supports a 12-byte "universal"
  23. format double that works well both with the 68881 fpu (which uses the top two
  24. bytes and the bottom 8 bytes) and with SANE (which uses the bottom 10 bytes).
  25. Thus in THINK C it is easy to mix modules compiled with (e.g. your code) and
  26. without (e.g. the ANSI library) the 68881 option. Unfortunately that excellent
  27. feature is unique to THINK C. In MPW and Metrowerks C you must use 10-byte
  28. doubles when you use SANE (i.e. don't use the 68881 fpu), so when you use these
  29. compilers you'll need separate pre-compiled headers, with and without the 68881
  30. option, if you want to compile for each environment: to use the 68881 fpu, or
  31. run on machines that lack it.
  32.  
  33. Metrowerks project names end in "µ", and indicate which cpu they support by
  34. "68k" or "ppc". THINK C projects support only the 68k and have names ending in
  35. "π".
  36.  
  37. My naming convention for pre-compiled headers indicates the size of int, "2i" or
  38. "4i", and, if the 68881 is required, "881". Metrowerks pre-compiled headers
  39. indicate which cpu they support by "68k" or "ppc"; THINK C supports only the
  40. 68k. The THINK C pre-compiled header that I use is "VideoToolbox.pre", which
  41. uses 2-byte ints and "universal" 12-byte doubles that work with or without the
  42. 68881. (The THINK C ANSI library requires 2-byte ints.) The Metrowerks
  43. CodeWarrior C pre-compiled headers that I use are called,
  44. "VideoToolbox.68k.4i.pre", "VideoToolbox.68k.4i.881.pre", and
  45. "VideoToolbox.ppc.pre".
  46.  
  47. MAC_C:
  48.  
  49. The Apple Macintosh header files use some extensions to C that are not part of
  50. Standard C, e.g. "pascal", "short double", enums larger than ints, and function
  51. prototypes that specify absolute addresses. These keywords and constructions
  52. cannot be compiled in Standard C. The macro MAC_C is defined as true, below,
  53. only on Macintosh C compilers that incorporate these extensions, and is false
  54. otherwise. The MAC_C symbol is used to prevent inclusion of all the
  55. Macintosh-dependent header files and prototypes when the compiler doesn't
  56. support them. However, lacking any general test for these extensions, a test
  57. must be added, below, for each new compiler. At present we test for Symantec's
  58. THINK C, Apple's MPW C, and Metrowerks CodeWarrior C.
  59.  
  60. MATLAB:
  61.  
  62. The VideoToolbox sources can be linked to create a stand-alone C application, or
  63. a MATLAB external code resource (a "MEX" file), to be invoked by typing the
  64. function name from within MATLAB. In that case we call the THINK C project a
  65. "MATLAB project". A MATLAB project must #define the symbol MATLAB as true for
  66. every C file, must #include the VideoToolbox.h header at the beginning of every
  67. C file, and must #include MATLABMain.h in the main C file.
  68.  
  69. Don't #define MATLAB within your C file; use the Edit:Options:THINK C:Prefix
  70. window instead. E.g. you could type
  71.     #define MATLAB 1
  72. into the Prefix window, or, more conveniently (because it speeds up your
  73. compilations enormously), type
  74.     #include "VideoToolboxMATLAB.pre"
  75. See VideoToolboxMATLAB.c for instructions.
  76.  
  77. The MATLABMain.h header allocates space for QuickDraw globals for use by THINK C
  78. MATLAB projects. It should be #included in the main C file of each THINK C
  79. MATLAB project, i.e. in the C file that contains "main" or "user_fcn". It must
  80. be included in exactly one source file of each project, as the THINK C Linker
  81. will otherwise complain.
  82.  
  83. dgp & dhb.
  84. Copyright 1989-1994 © Denis G. Pelli
  85.  
  86. HISTORY: (omitting changes documented in C files)
  87. 2/20/93 dhb    Added various commonly used headers.  
  88.             Restructured so that only VideoToolbox.h has to be included,
  89.             whether one is creating stand-alone THINK C or code resources
  90.             to be called by MATLAB. Everything that cares is properly conditioned
  91.             by the symbol MATLAB.
  92. 7/9/93    dgp    Changed our convention for the MATLAB symbol, defining it as
  93.             1 or 0 instead of defining or leaving undefined. The advantage of
  94.             this approach is that "MATLAB" can now be used as an argument in an
  95.             ordinary if statement, which is much more readable than #if.
  96. 8/21/93    dhb    Added undefs in #if MATLAB so that memory allocation goes through THINK C 
  97.             library, not as callback. Callbacks would be OK except that the Mathworks 
  98.             forgot to give us one for realloc. This leads to mixing memory managers
  99.              on the same pointers -- bad bad bad.
  100. 9/2/93    dhb    commented out #include <TranslateLinefeeds.h> since it's
  101.             not presently compatible with MATLAB.
  102. 9/2/93    dgp    Moved the NL and NEWLINE macros from Assign.c into this file.
  103. 9/8/93    dgp    Mention VideoToolbox.c.
  104. 9/11/93    dhb,dgp    Define STDIO_INT and STDIO_DOUBLE.
  105. 9/12/93    dhb    Change STDIO_... to PRINTF_... and SCANF_...
  106.             Insert conditional for MATLAB 3.5 vs. 4.x
  107. 9/14/93    dhb    Conditional for MATLAB changed to make symbol match major version number.
  108.             Removed traces of old trying to force 4 byte ints for MATLAB.
  109. 9/14/93    dgp    Moved up inclusion of QuickDraw.h before MATLAB stuff, since cmex.h
  110.             requires it. Fixed typo, changing "#elseif" to "#elif".
  111. 9/15/93    dgp    Edited the comments above, referring to VideoToolbox.c and the new 
  112.             VideoToolboxMATLAB.c.
  113. 9/16/93    dgp    Added contents of former Assign.h.
  114.             Defined MAC_C so that the VideoToolbox.h header may be used with
  115.             Standard C.
  116. 9/16/93    dhb Removed prototype for obsolete GetDateTimeString.
  117. 10/2/93    dgp    Added #include <Errors.h>.
  118. 12/1/93 dgp Now always write "MATLAB" in all caps, since that's the trademarked name.
  119. 12/16/93 dhb Somewhere things got munged.  Conditional for MATLAB version appeared
  120.            before inclusion of cmex, which won't work.  I fixed the order.
  121. 12/16/93 dhb Commented out inclusion of TranslateLineFeeds.h down below.  This
  122.            generates a link error from MATLAB.
  123. 12/29/93 dgp added #include <Packages.h>
  124. 6/12/94  dgp added definition of Apple's new BlockMoveData, for compatibility with
  125.             Apple's old pre-Universal header files.
  126. 6/12/94    dgp #include Strings.h if Universal header files are used.
  127. 7/28/94 dgp Added test for Metrowerks CodeWarrior C.
  128. 9/2/94    dgp #include MacMemory.h
  129. 9/5/94    dgp changed "int" to "short int" in definitions of PRINTF_INT and SCANF_INT for
  130.             MATLAB 4. This is based on common sense, not testing or detailed knowledge.
  131. */
  132. #pragma once            /*  suppress multiple inclusions of this file */
  133. #ifndef _VIDEOTOOLBOX_    /*  suppress multiple inclusions of this file */
  134. #define _VIDEOTOOLBOX_
  135. /*
  136. Header files that are required for successful compilation of the rest of this
  137. file are marked "required".
  138. */
  139. #if THINK_C                /* THINK C */    \
  140.     || applec            /* MPW C, presumably with Mac extensions */\
  141.     || __MWERKS__        /* Metrowerks CodeWarrior C, " */
  142.     #if THINK_C
  143.         #if __option(thinkc)
  144.             #define MAC_C 1        /* allow Macintosh C extensions: "pascal", "short double", etc. */
  145.         #else
  146.             #define MAC_C 0        /* Standard C */
  147.         #endif
  148.     #else
  149.         #define MAC_C 1            /* allow Macintosh C extensions: "pascal", "short double", etc. */
  150.     #endif
  151. #else
  152.     #define MAC_C 0                /* Standard C */
  153. #endif
  154. #ifndef SHORT_DOUBLE_OK
  155.     #define SHORT_DOUBLE_OK MAC_C    /* "short double" not allowed by Standard C */
  156. #endif
  157. #include <stdio.h>            /*  required */
  158. #include <stdlib.h>
  159. #if MAC_C
  160.     #include <Quickdraw.h>    /*  required */
  161. #endif
  162. #ifndef MATLAB
  163.     #define MATLAB 0
  164. #endif
  165. #if MATLAB
  166.     /*
  167.     This must come after stdlib.h, stdio.h, and QuickDraw.h and before everything
  168.     else. If MATLAB is true then we include the header file cmex.h.  Otherwise we
  169.     define the data types that are normally provided by that header, so that code
  170.     that uses these types may be compiled for use in applications.  It must come
  171.     before we test for version 3 or 4.  The version 3 cmex.h does not define the
  172.     symbol mex_h; version 4 does.  This is what we use to figure out which
  173.     version we are compiling for.  Sound complicated?  Sigh!
  174.     */
  175.     
  176.     #include <cmex.h>
  177.     // Test for MATLAB 4 or MATLAB 3, and set symbol appropriately.
  178.     #undef MATLAB
  179.     #ifdef mex_h
  180.         #define MATLAB 4
  181.     #else
  182.         #define MATLAB 3
  183.     #endif
  184.     #ifndef MAC_C
  185.         #error "MATLAB requires the Macintosh extensions to C."
  186.     #endif
  187.  
  188.     // Undefine the macros that override memory allocation.  MATLAB's implementation
  189.     // doesn't work if you use realloc.
  190.     #undef malloc
  191.     #undef calloc
  192.     #undef free
  193.     
  194.     // Define data types for printf, scanf.
  195.     #if (MATLAB == 4)                        /* Version 4 */
  196.         typedef short int PRINTF_INT;        /* type of arguments to printf et al. */
  197.         typedef long double PRINTF_DOUBLE;
  198.         typedef short int SCANF_INT;        /* type of arguments to scanf et al. */
  199.         typedef double SCANF_DOUBLE;
  200.     #elif (MATLAB == 3)                        /* Version 3.5 */
  201.         typedef long int PRINTF_INT;        /* type of arguments to printf et al. */
  202.         typedef double PRINTF_DOUBLE;
  203.         typedef short int SCANF_INT;        /* type of arguments to scanf et al. */
  204.         typedef long double SCANF_DOUBLE;    
  205.     #endif
  206.     #ifdef THINK_C    /* Declare our own QuickDraw globals, allocated by MATLABMain.h */
  207.         extern THINK_C_QD mex_qd;
  208.         #define qd mex_qd
  209.     #else
  210.         #define mex_qd qd
  211.     #endif
  212.     #if defined(MAIN)                        /* Some old programs #define MAIN. */
  213.         #include "MATLABMain.h"                /* New programs just #include directly. */
  214.     #endif
  215. #else
  216.     typedef long int INT;
  217.     #if SHORT_DOUBLE_OK
  218.         typedef short double DOUBLE;/* not allowed by Standard C */
  219.     #endif
  220.     typedef int PRINTF_INT;            /* type of arguments to printf et al. */
  221.     typedef double PRINTF_DOUBLE;
  222.     typedef int SCANF_INT;            /* type of arguments to scanf et al. */
  223.     typedef double SCANF_DOUBLE;
  224.     #if SHORT_DOUBLE_OK
  225.         typedef struct {
  226.             char *name;
  227.             INT type;
  228.             INT m;
  229.             INT n;
  230.             DOUBLE *pr;
  231.             DOUBLE *pi;
  232.         } Matrix;
  233.     #endif
  234. #endif
  235.  
  236. /*  Standard C headers */
  237. #include <ctype.h>
  238. #include <float.h>
  239. #include <limits.h>
  240. #include <string.h>
  241. #include <time.h>
  242.  
  243. /*  Macintosh headers */
  244. /*
  245. The inclusion, above, of Quickdraw.h will result in the inclusion of MixedMode.h
  246. only if the Universal Headers are used, since the Universal Headers and the Mixed
  247. Mode Manager are both new, providing universal support for 68k and ppc Macs.
  248. */
  249. #if defined(__MIXEDMODE__)
  250.     #define UNIVERSAL_HEADERS 1
  251. #else
  252.     #define UNIVERSAL_HEADERS 0
  253. #endif
  254. #if MAC_C
  255.     #if THINK_C
  256.         #include <console.h>
  257.     #endif
  258.     #include <Devices.h>
  259.     #include <Errors.h>
  260.     #include <Events.h>
  261.     #include <FixMath.h>    /*  Must come before mc68881.h */
  262.     #include <Fonts.h>
  263.     #include <GestaltEqu.h>
  264.     #include <Memory.h>
  265.     #include <OSEvents.h>
  266.     #include <OSUtils.h>    /*  required */
  267.     #include <Packages.h>
  268.     #include <Palettes.h>
  269.     #if THINK_C
  270.         #include <profile.h>/* only needed if you want timing info */
  271.     #endif
  272.     #include <QDOffscreen.h>
  273.     #include <Resources.h>
  274.     #include <Retrace.h>    /*  required */
  275.     #include <Slots.h>
  276.     #include <Sound.h>
  277.     #if !defined(THINK_C) || UNIVERSAL_HEADERS
  278.         #include <Strings.h>/* c2pstr() and p2cstr() */
  279.         #define CtoPstr c2pstr
  280.         #define PtoCstr p2cstr
  281.     #else
  282.         #include <pascal.h>    /* CtoPStr() and PtoCStr() */
  283.         #ifndef c2pstr
  284.             #define c2pstr(s) CtoPstr(s)
  285.             #define p2cstr(s) PtoCstr(s)
  286.         #endif
  287.     #endif
  288.     #include <Timer.h>        /*  required */
  289.     #include <ToolUtils.h>
  290.     #include <Video.h>
  291.     #include <Windows.h>    /*  required */
  292.     // Old Memory.h header files, before Apple's Universal Headers, don't define the new
  293.     // BlockMoveData(), so we do it here, to retain compability with the old header files.
  294.     #if !UNIVERSAL_HEADERS
  295.         #pragma parameter BlockMoveData(__A0,__A1,__D0)
  296.         extern pascal void BlockMoveData(const void *srcPtr,void *destPtr,Size byteCount)=0xA22E;
  297.     #endif
  298. #endif
  299.  
  300. /*
  301. This redefines the standard C functions, malloc, etc. to instead call Apple's
  302. corresponding routines, e.g. NewPtr. The THINK C memory management routines are 
  303. poor because they are bad about freeing space, tending to fragment the free space. 
  304. */
  305. #if THINK_C
  306.     #include "MacMemory.h"
  307. #endif
  308.  
  309. /*
  310. MATLAB AND THE NEWLINE CHARACTER
  311. In most C environments the newline character is '\n' (ascii 10). In Apple's
  312. wisdom they chose to separate lines in Macintosh files with the ascii 13
  313. character, which is usually called the return character '\r'. Standard C
  314. specifies that the stdio library will use '\n' as the newline character. This
  315. potentially creates a compatibility problem between Mac C programs and C
  316. programs written for the rest of the world's computers, since one wants any text
  317. files they produce to be appropriate to the local environment. Both MPW and
  318. THINK C resolve the problem behind the scenes, but they do it in different ways.
  319. MPW redefines the association between symbolic names and character codes, making
  320. '\n' be 13 and '\r' be 10. THINK C instead modifies the stdio library so that
  321. reads and writes to a "text" (i.e. not binary) stream are translated, exchanging
  322. character codes 10 and 13. Both solutions work. However, when we use THINK C to
  323. create code resources for MATLAB we are forced to use the MPW stdio library that
  324. is built into MATLAB. Unfortunately this bypasses both compilers' fixes to the
  325. newline problem. The problem affects every single text i/o operation, e.g. every
  326. printf and scanf. Alas, there is no way to get the pre-processor to redefine /n
  327. and /r.
  328.  
  329. We have attempted two solutions: a quick fix, using macros NL and NEWLINE, and a
  330. complete clean fix, using TranslateLinefeeds.c. At present only the quick fix
  331. works.
  332.  
  333. Our quick fix is to create a macro called NL that is normally defined as the
  334. newline string "\n", but which is instead defined as "\015" (i.e. ascii 13) when
  335. MATLAB is true. Programs such as Assign.c that have replaced all instances of
  336. "\n" by NL will then work whether or not MATLAB is true. The obvious drawback is
  337. that this quick solution requires these modifications to the source files.
  338.  
  339. The clean relatively complete solution is to insert a filter,
  340. TranslateLinefeeds.c, that intercepts the calls to the stdio library and
  341. translates /r to /n and vice versa for i/o to text files. The header file
  342. TranslateLinefeeds.h redefines all the stdio calls as macros that call
  343. corresponding routines within TranslateLinefeeds.c. Note that scanf is not
  344. intercepted and that for printf (and fprintf, ...) only the format string
  345. is translated; linefeeds hiding in char or string arguments in the variable
  346. part of the argument list are not be translated.
  347. */
  348. #if MATLAB && THINK_C            /* Clean, relatively complete solution */
  349.     //#include <TranslateLinefeeds.h>
  350. #endif
  351. #if !defined(_TranslateLinefeeds_) && MATLAB && THINK_C    /* Quick fix */
  352.     #define NL "\r"
  353.     #define NEWLINE '\r'
  354. #else
  355.     #define NL "\n"        /* the standard new-line string */
  356.     #define NEWLINE '\n'
  357. #endif
  358.  
  359. /*
  360. TRUE and FALSE
  361. */
  362. #ifndef TRUE
  363.     #define FALSE    0
  364.     #define TRUE    1
  365. #endif
  366.  
  367. /*
  368. NAN & INF
  369. If you're using NAN and INF you'll be interested in the IsNan(), IsInf(), and
  370. IsFinite() definitions & prototypes below. When compiling for a PowerPC, 
  371. math.h includes the fp.h header, which defines INFINITY and NAN.
  372. */
  373. #if !defined(INF)
  374.     #define INF HUGE_VAL    /* defined in math.h */
  375. #endif
  376. #if !defined(NAN) && !defined(powerc)
  377. //    #define NAN    (0.0/0.0)    /* evaluated at runtime */
  378.     #define NAN    Nan            /* global defined in Nan.c */
  379. #endif
  380.  
  381. /*
  382. NUMERICAL CONSTANTS
  383. It's sad to say, but THINK C 5.02 loses two bits of precision converting between
  384. doubles and ascii text, in either direction. Thus you will obtain more accurate
  385. results by computing the numerical constants below at runtime rather than using
  386. these predefined constants. The ANSI Numerical C Extensions group is moving to
  387. require C compilers to preserve precision, so there is hope for the future. Of
  388. course most applications would never notice a loss of two bits precision out of
  389. the total double precision given by the 64 bits in the mantissa.
  390. */
  391. #if !defined(PI)
  392.     #define PI        3.1415926535897932385    /* computed in Mathematica */
  393. #endif
  394. #if !defined(LOGPI)
  395.     #define LOGPI    1.14472988584940017414    /* computed in Mathematica */
  396. #endif
  397. #if !defined(LOG2)
  398.     #define LOG2    0.69314718055994530942    /* computed in Mathematica */
  399. #endif
  400. #if !defined(LOG10)
  401.     #define LOG10    2.30258509299404568402    /* computed in Mathematica */
  402. #endif
  403.  
  404. #if MAC_C
  405.     /*
  406.     CLUTSIZE
  407.     Inline code that returns the same answer as GDClutSize(device).
  408.     */
  409.     #define GDCLUTSIZE(device) (gdClutSizeTable[(**(**(device)).gdPMap).pixelSize])
  410.     
  411.     /*  Commented out, because its answer is misleading when in 16-bit or 32-bit mode. */
  412.     /* #define GDCOLORS(device) ((**(**(**device).gdPMap).pmTable).ctSize+1) */
  413. #endif
  414.  
  415. /*
  416. FIXED POINT ARITHMETIC
  417. Apple defines a handy data type called Fixed that is stored in a long, but is
  418. assumed to have a decimal point in the middle. Many operations, e.g. adding two
  419. Fixed numbers or multiplying or dividing a Fixed by an integer, can be performed
  420. directly. To multiply or divide two Fixed numbers use Apple's FixMul() and
  421. FixDiv(). FixRatio(n,m) returns the Fixed ratio of two integers. Macintosh C
  422. compilers define double in various ways, depending on whether a floating point
  423. unit is to be used. The Apple-provided routines for doing type conversion to and
  424. from Fixed are only appropriate if you are NOT using the floating point unit.
  425. The ones defined below are faster and work with or without the FPU.
  426. */
  427. #define LongToFix(x) ((long)(x)<<16)
  428. #define FixToLong(x) ((x)>>16)
  429. #define DoubleToFix(x) ((long)((x)*65536.+0.5))
  430. #define FixToDouble(x) ((double)(x)*(1./65536.))
  431.  
  432. #if MAC_C
  433.     /*
  434.     STACK
  435.     StackGrow(n) increases the stack allocation by n bytes. You'll also want to use
  436.     Apple's StackSpace(), declared in Memory.h, that returns the number of bytes 
  437.     allocated for the stack.
  438.     */
  439.     #define StackGrow(extraBytes) SetApplLimit(GetApplLimit()-(extraBytes))
  440. #endif
  441.  
  442. /* Assign.c */
  443.  
  444. #define ASSIGN_DIMS 3        /* Feel free to increase or decrease ASSIGN_DIMS. */
  445. typedef struct {
  446.     short type;
  447.     unsigned sizedOnce:1;    /* dim[] is meaningful */
  448.     unsigned sized:1;        /* dim[] is final */
  449.     unsigned malloced:1;    /* allocated by malloc */
  450.     char *name;
  451.     void *ptr;                /* for array, address of element zero */
  452.     long dim[ASSIGN_DIMS];    /* zero indicates a scalar */
  453.     long firstElement;        /* for 1-d array, index of first array element. Usually 0 */
  454.     const char *comment;    /* text string, or NULL */
  455. } Description;
  456. enum{assignReportUnknown=1,assignNoHexInts=2,assignHexFloats=4
  457.     ,assignNoComment=8,assignNoPrintfExit=0x10
  458.     ,assignEchoAssignments=0x20,assignEchoComments=0x40,assignEchoFile=0x80
  459. };
  460. enum {assignMemoryError=-1,assignTypeError=-2
  461.     ,assignVariableError=-3,assignUnknownVariableError=-4
  462.     ,assignSubscriptError=-5,assignSubscriptBoundsError=-6
  463.     ,assignEqualsError=-7,assignConstantError=-8,assignHexError=-9
  464.     ,assignSemicolonError=-10,assignFileError=-11
  465.     ,assignInconsistentDescriptionsError=-12,assignUnequalDataError=-13
  466.     ,assignInconsistentDimensionsError=-14
  467.     ,assignCouldntFindDescription=-15
  468. };
  469. enum{charType=1,unsignedCharType,shortType,unsignedShortType
  470.     ,longType,unsignedLongType
  471.     ,floatType
  472.     #if SHORT_DOUBLE_OK
  473.         ,shortDoubleType
  474.     #endif
  475.     ,doubleType
  476.     ,charPtrType,unsignedCharPtrType,shortPtrType,unsignedShortPtrType
  477.     ,longPtrType,unsignedLongPtrType
  478.     ,floatPtrType
  479.     #if SHORT_DOUBLE_OK
  480.         ,shortDoublePtrType
  481.     #endif
  482.     ,doublePtrType
  483.     ,stringType,unknownType
  484. };
  485. FILE *OpenCalFileRead(char *filename);
  486. FILE *OpenCalFileReadAndCheck(char *filename);
  487. FILE *OpenCalFileWrite(char *filename);
  488. void AppendDescriptions(Description **d,Description *s);
  489. void CopyDescriptions(Description *d,Description *s);
  490. Description *AllocateDescriptions(long n);
  491. void FreeDescriptions(Description *d);
  492. long NumberOfDescriptions(Description *d);
  493. Description NullDescription(void);
  494. int IsNullDescription(Description d);
  495. #define IsNullDescription(d) ((d).type==0)
  496. int AssignmentLineWasBlank(void);
  497. int UnequalDescribedVars(Description d1[],Description d2[],short flags);
  498. int UnequalDescribedVarPair(Description *d1,Description *d2,short flags);
  499. int CopyDescribedVars(Description d1[],Description d2[],short flags);
  500. int CopyDescribedVarPair(Description *d1,Description *d2,short flags);
  501. long InitializeADescribedVar(Description *d,short flags);
  502. long InitializeDescribedVars(Description d[],short flags);
  503. long FindDescribedDim(Description d[],void *ptr,int i,short flags);
  504. long FindDescription(Description d[],void *ptr,short flags);
  505. void FreeADescribedVar(Description *d,short flags);
  506. void FreeDescribedPtrVars(Description d[],short flags);
  507. void FreeDescribedVars(Description d[],short flags);
  508. void KeepDescribedVars(Description d[],short flags);
  509. void KeepADescribedVar(Description *d,short flags);
  510. long PrintAnAssignment(FILE *stream,Description *d,short flags);
  511. long PrintAssignments(FILE *stream,Description d[],short flags);
  512. long PrintAssignmentsToFile(const char *filename,Description d[],short flags);
  513. long ReadAssignmentLine(FILE *stream,Description d[],short flags);
  514. long ReadAssignmentBlock(FILE *stream,Description d[],short flags);
  515. long ReadAssignmentStream(FILE *stream,Description d[],short flags);
  516. long ReadAssignmentFile(const char *filename,Description d[],short flags);
  517. Description Describe(short type,void *ptr,char *name,const char *comment);
  518. Description DescribeArray(short type,void *ptr,char *name,const char *comment,...);
  519. Description DescribeFirstLast(short type,void *ptr,char *name
  520.     ,const char *comment,long firstElement,long lastElement);
  521.  
  522. /* Binomial.c */
  523.  
  524. long    BinomialSample(double p,long n);
  525. int        BinomialSampleQuickly(int n);
  526. double    BinomialLowerBound(double P,long k,long n);
  527. double    BinomialUpperBound(double P,long k,long n);
  528. double    BinomialPdf(double p,long k,long n);
  529. double    Binomial(double p,long k,long n);
  530. double    IncompleteBeta(double x,double a,double b);
  531. double    InverseBinomial(double P,long k,long n);
  532. double    InverseIncompleteBeta(double p,double a,double b);
  533.  
  534. /* BreakLines.c */
  535.  
  536. char *BreakLines(char *string,long lineLength);
  537. void PrintWrappedText(FILE *stream,const char *s);
  538. void PrintWrappedTextToFile(const char *filename,const char *s);
  539. void PrintWrappedComment(FILE *stream,const char *s);
  540. void PrintWrappedCommentToFile(const char *filename,const char *s);
  541.  
  542. #if MAC_C
  543.     /* CardSlot.c */
  544.     
  545.     OSErr    CardSlot(char *cardName);
  546.     
  547.     /* CenterRectInRect.c */
  548.     
  549.     void    CenterRectInRect(Rect *moveableRectPtr,Rect *fixedRectPtr);
  550.     void    OffsetRectTile(Rect *r,int nx,int ny);
  551.     Boolean    RectInRect(Rect *r,Rect *R);
  552. #endif
  553.  
  554. /* ChiSquare.c */
  555.  
  556. double    PChiSquare (double chiSquare,int n);
  557.  
  558. /* Choose.c */
  559.  
  560. #if !MAC_C
  561.     #define Boolean unsigned char
  562. #endif
  563. int Choose(int defaultChoice,const char *query,char *choices[],int n);
  564. char *ChoiceStr(char *choices[],int n);
  565. int MultipleChoice(short defaultChoice,short n,char *choices[]);
  566. Boolean YesOrNo(Boolean defaultAnswer);
  567. extern char *noYes[];
  568. #if !MAC_C
  569.     #undef Boolean
  570. #endif
  571.  
  572. #if MAC_C
  573.     /* ChooseScreen.c */
  574.     
  575.     int ChooseScreen(int screen,const char *question);
  576.  
  577.     /* ConvolveX.c */
  578.     
  579.     void    ConvolveX(double f[],int dim,BitMap *srcBits,BitMap *dstBits,
  580.                 Rect *srcRectPtr,Rect *dstRectPtr);
  581.  
  582.     /* ConvolveY.c */
  583.     
  584.     void ConvolveY(double f[],int dim,BitMap *srcBits,BitMap *dstBits,
  585.                 Rect *srcRectPtr,Rect *dstRectPtr);
  586.     
  587.     /* CopyBitsQuickly.c */
  588.     
  589.     enum{addOverQuickly=40,addOverParallel=40,mulOver};
  590.     int    CopyBitsQuickly(BitMap *srcBits,BitMap *dstBits
  591.         ,Rect *srcRectPtr,Rect *dstRectPtr,long srcMode,RgnHandle maskRgn);
  592.     
  593.     /* CopyQuickDrawGlobals.c */
  594.     
  595.     void CopyQuickDrawGlobals(void);
  596.     #define CopyQuickdrawGlobals CopyQuickDrawGlobals    /*  old spelling */
  597.     
  598.     /* CopyWindows.c */
  599.     
  600.     enum{copyLiterally=0x10000,copyColorize=0x20000};
  601.     enum{srcCopyLiterally=srcCopy+copyLiterally,addOverLiterally=addOver+copyLiterally
  602.         ,addOverParallelLiterally=addOverParallel+copyLiterally
  603.         ,mulOverLiterally=mulOver+copyLiterally};
  604.     int CopyWindows(CWindowPtr srcWindow,CWindowPtr dstWindow
  605.         ,Rect *srcRectPtr,Rect *dstRectPtr,long srcMode,RgnHandle maskRgn);
  606.  
  607.     /* CreateTrialSnds.c */
  608.     
  609.     void CreateTrialSnds(void);
  610. #endif
  611.  
  612. /* DatedString.c */
  613.  
  614. char    *DatedString(unsigned long seconds);
  615.  
  616. #if MAC_C
  617.     /* DrawPrintf.c */
  618.     
  619.     void DrawPrintf(char *s, ...);
  620. #endif
  621.  
  622. /* Exponential.c */
  623.  
  624. double ExponentialPdf(double x);
  625.  
  626. /* ffprintf.c */
  627.  
  628. int ffprintf(FILE *stream[2],char *format,...);
  629.  
  630. #if MAC_C
  631.     /* FlushCacheRange.c */
  632.     
  633.     void FlushCacheRange (void *address, unsigned long count);
  634.     
  635.     /* fp.c */
  636.     
  637.     /* These 3 prototypes appear in Apple's fp.h, but only when it's compiled for */
  638.     /* the PowerPC, not for the 68k. Apple has promised to eventually make the routines */
  639.     /* available on both platforms. In the meantime the VideoToolbox provides the routines */
  640.     /* for 68k machines, so that your programs can use these functions without worrying */
  641.     /* about which platform you might run on. */
  642.     /* Apple's current header files define extended80 in <Types.h>. However, some older */
  643.     /* compilers may have old header files that only define extended80 in <SANE.h>. */
  644.     /* In that case, comment out any offending prototypes below, and paste them */
  645.     /* directly into your source files, after "#include <SANE.h>". The SANE.h header */
  646.     /* file has side effects, so you shouldn't include it here */
  647.     /* or in any file that doesn't really need it. Alternatively, instead of including */
  648.     /* all of SANE.h, you could just copy the definition of extended80. We can't do that */
  649.     /* here because it's an error to repeat a typedef. */
  650.  
  651.     #if !__powerc
  652.         void ldtox80(long double *x,extended80 *x80);
  653.         void x80told(extended80 *x80,long double *x);
  654.         long int fpclassify(double x);
  655.     #endif
  656.  
  657.     /* GDOpenWindow.c */
  658.     
  659.     void AddExplicitPalette(WindowPtr window);
  660.     void RemovePalette(WindowPtr window);
  661.     WindowPtr GDOpenWindow1(GDHandle device);
  662.     void GDDisposeWindow1(WindowPtr window);
  663.     CWindowPtr GDOpenWindow(GDHandle device);
  664.     void GDDisposeWindow(CWindowPtr myWindow);
  665.     void GDGrayColorTable(GDHandle device);
  666.     void SwapWindowExplicitMode(CWindowPtr window,Boolean *explicit);
  667.     BitMap *GetBitMapPtr(CWindowPtr window);
  668.     Boolean IsOffScreen(CWindowPtr window);
  669.     Boolean IsWindow(CWindowPtr window);
  670.     
  671.     /* GDPrintf.c */
  672.     
  673.     void GDPrintf(char *s, ...);
  674.     
  675.     /* GDTime.c */
  676.     
  677.     double GDFrameRate(GDHandle device);
  678.     double GDMovieRate(GDHandle device,int quickly);
  679.     double GDMovieSize(GDHandle device,int quickly);
  680.     double GDVBLRate(GDHandle device);
  681.     double TickRate(void);
  682.     typedef OSErr (*SetEntriesFunction)(GDHandle device,short start,short count
  683.         ,ColorSpec *aTable);
  684.     OSErr GDTimeClut(GDHandle device,SetEntriesFunction function,short clutEntries
  685.         ,double *sPtr,double *framesPtr,double *missingFramesPtr,double *frameRatePtr);
  686.     
  687.     /* GDVideo.c */
  688.     
  689.     #define MAX_SCREENS 8
  690.     char  *GDCardName(GDHandle device);
  691.     extern short gdClutSizeTable[33];
  692.     short GDClutSize(GDHandle device);
  693.     long GDColors(GDHandle device);
  694.     OSErr GDControl(int refNum,int csCode,Ptr csParamPtr);
  695.     short GDDacSize(GDHandle device);
  696.     OSErr GDDirectSetEntries(GDHandle device,short start,short count,ColorSpec *aTable);
  697.     OSErr GDGetDefaultGamma(GDHandle device,GammaTbl **gammaTbl);
  698.     OSErr GDGetDefaultMode(GDHandle device,short *modePtr);
  699.     OSErr GDGetEntries(GDHandle device,short start,short count,ColorSpec *aTable);
  700.     OSErr GDGetGamma(GDHandle device,GammaTbl **myGammaTblHandle);
  701.     OSErr GDGetGray(GDHandle device,Boolean *flagPtr);
  702.     OSErr GDGetInterrupt(GDHandle device,Boolean *flagPtr);
  703.     OSErr GDGetMode(GDHandle device,short *modePtr,short *pagePtr,Ptr *baseAddrPtr);
  704.     OSErr GDGetPageBase(GDHandle device,short page,Ptr *baseAddrPtr);
  705.     OSErr GDGetPageCnt(GDHandle device,short mode,short *pagesPtr);
  706.     OSErr GDGrayPage(GDHandle device,short page);
  707.     Boolean GDHasMode(GDHandle device,short mode,short *pixelSizePtr,short *pagesPtr);
  708.     #define GDLinearGamma GDUncorrectedGamma /* old name, before 12/16/92 */
  709.     short GDModePixelSize(GDHandle device,short mode);
  710.     unsigned char *GDName(GDHandle device);
  711.     char *GDNameStr(GDHandle device);
  712.     ColorSpec *GDNewLinearColorTable(GDHandle device);
  713.     short GDPixelSize(GDHandle device);
  714.     OSErr GDPrintGammaTable(FILE *o,GDHandle device);
  715.     OSErr GDReset(GDHandle device,short *modePtr,short *pagePtr,Ptr *baseAddrPtr);
  716.     OSErr GDRestoreDeviceClut(GDHandle device);
  717.     OSErr GDRestoreGamma(GDHandle device);
  718.     OSErr GDSaveGamma(GDHandle device);
  719.     OSErr GDSetDefaultMode(GDHandle device,short mode);
  720.     OSErr GDSetEntries(GDHandle device,short start,short count,ColorSpec *aTable);
  721.     OSErr GDSetEntriesByType(GDHandle device,short start,short count,ColorSpec *table);
  722.     OSErr GDSetEntriesByTypeHighPriority(GDHandle device,short start,short count
  723.         ,ColorSpec *table);
  724.     OSErr GDSetGamma(GDHandle device,GammaTbl *myGammaTblPtr);
  725.     OSErr GDSetGray(GDHandle device,Boolean flag);
  726.     OSErr GDSetInterrupt(GDHandle device,Boolean flag);
  727.     OSErr GDSetMode(GDHandle device,short mode,short page,Ptr *baseAddrPtr);
  728.     OSErr GDSetPageDrawn(GDHandle device,short page);
  729.     OSErr GDSetPageShown(GDHandle device,short page);
  730.     OSErr GDStatus(int refNum,int csCode,Ptr csParamPtr);
  731.     short GDType(GDHandle device);
  732.     OSErr GDUncorrectedGamma(GDHandle device);
  733.     int  GDVersion(GDHandle device);
  734.     #define ModeName GDModeName   /* old name, before 1/18/93 */
  735.     int  PatchMacIIciVideoDriver(void);
  736.     
  737.     /* GetClicks.c */
  738.     
  739.     short    GetClicks(void);
  740. #endif
  741.  
  742. /* GetTimeDateString.c */
  743.  
  744. char *GetTimeDateString(time_t t);
  745.  
  746. #if MAC_C
  747.     /* GetVersionString.c */
  748.  
  749.     char *GetVersionString(void);
  750.  
  751.     /* GetScreenDevice.c */
  752.     
  753.     GDHandle    GetScreenDevice(int n);
  754.     int            GetScreenIndex(GDHandle device);
  755.     GDHandle    SlotToScreenDevice(int n);
  756.     short int    GetDeviceSlot(GDHandle device);
  757.     GDHandle    GetWindowDevice(WindowPtr theWindow);
  758.     GDHandle    GetRectDevice(Rect *r);
  759.     void        LocalToGlobalRect(Rect *r);
  760.     void        GlobalToLocalRect(Rect *r);
  761.  
  762.     /* GetVoltage.c */
  763.     
  764.     double    VoltsDuringFrame(double frames);
  765.     double    GetVoltage(short channel,double *gainPtr,double *frequencyPtr,long n
  766.                 ,double *sdPtr);
  767.     short    GetVoltages(short channel,double *gainPtr,double *frequencyPtr,long *nPtr
  768.                 ,unsigned short readings[],double *voltDeltaPtr,double *voltZeroPtr);
  769.     short    InitiateVoltageSampling(short channel,double *gainPtr,double *frequencyPtr
  770.                 ,double *voltDeltaPtr,double *voltZeroPtr);
  771.     short    RetrieveVoltages(long *nPtr,unsigned short readings[]);
  772.     int        ForeRunnerSlot(void);
  773.     enum{voltageBufferOverflow=1<<0,voltageOverflow=1<<1,voltageUnderflow=1<<2};
  774. #endif
  775.  
  776. /* HexToBinary.c */
  777.  
  778. int HexToBinary(char *string,void *ptr);
  779. char *BinaryToHex(size_t n,void *ptr,char *string);
  780.  
  781. #if MAC_C
  782.     /* HideMenuBar.c */
  783.     
  784.     void    HideMenuBar(void);
  785.     void    ShowMenuBar(void);
  786.     void SquareCorners(GDHandle device);
  787.     void RestoreCorners(GDHandle device);
  788.     void UnclipScreen(GDHandle device);
  789.     void RestoreScreenClipping(GDHandle device);
  790.     
  791.     /* Identify.c */
  792.     
  793.     char *IdentifyApplication(void);
  794.     char *IdentifyCompiler(void);
  795.     char *IdentifyMachine(void);
  796.     char *IdentifyModel(void);
  797.     char *IdentifyOwner(void);
  798.     char *IdentifyVideo(GDHandle device);
  799.     
  800.     /* ImageStatistics */
  801.  
  802.     double ImageEnergy(GWorldPtr aWorld,Rect *aRect,double background);
  803.     void ImageStatistics(GWorldPtr world,Rect *rect
  804.         ,long *minPtr,long *maxPtr,double *meanPtr,double *meanSquarePtr);
  805.  
  806.     /* IsCmdPeriod.c */
  807.     
  808.     Boolean IsCmdPeriod(EventRecord *event);
  809. #endif
  810.  
  811. /* IsNan.c */
  812.  
  813. int IsNan(double x);
  814. int IsInf(double x);
  815. #ifndef IsFinite    /* neither NAN nor ±INF */
  816.     #define IsFinite(x) \
  817.     (sizeof(x)>8?    \
  818.     ((*(short *)&(x) & 0x7FFF)!=0x7FFF)        /* 10 or 12 byte double */\
  819.     :((*(short *)&(x) & 0x7FF0)!=0x7FF0))    /* 8 byte double */
  820. #endif
  821.  
  822. #if MAC_C
  823.     /* kbhit.c */
  824.     
  825.     int    kbhit(void);
  826.     int    getcharUnbuffered(void);
  827. #endif
  828.  
  829. /* Log2L.c */
  830.  
  831. long Log2L(unsigned long j);
  832.  
  833. #if MAC_C
  834.     /* MakeNoise.c */
  835.     
  836.     int FillWindowWithNoise(CWindowPtr window,double dx,double dy,Boolean randomPhase);
  837.     int MakeNoise1(double dx,double dy,Boolean randomPhase,PixMap *frame);
  838.     
  839.     /* MaximizeConsoleHeight.c */
  840.     
  841.     void MaximizeConsoleHeight(void);
  842. #endif
  843.  
  844. /* Mean.c */
  845.  
  846. double Mean(double x[],long n,double *sdPtr);
  847. double MeanF(float x[],long n,double *sdPtr);
  848. double MeanB(char x[],long n,double *sdPtr);
  849. double MeanUB(unsigned char x[],long n,double *sdPtr);
  850. double MeanW(short x[],long n,double *sdPtr);
  851. double MeanUW(unsigned short x[],long n,double *sdPtr);
  852. double MeanL(long x[],long n,double *sdPtr);
  853. double MeanUL(unsigned long x[],long n,double *sdPtr);
  854.  
  855. /* Nan.c */
  856. extern const short __NAN[];
  857. #define Nan (*(double *)__NAN)
  858.  
  859. /* Normal.c */
  860.  
  861. double NormalPdf(double x);
  862. double Normal(double x);
  863. double InverseNormal(double p);
  864. double NormalSample(void);
  865. double Normal2DPdf(double r);
  866. double Normal2D(double r);
  867. double InverseNormal2D(double p);
  868. double Normal2DSample(void);
  869. double InverseNormal2DPdf(double p);
  870. void BoundedNormalIntegers(short *distribution,long n,double mean,double sd
  871.     ,short min,short max);
  872.  
  873. /* nrand.c */
  874.  
  875. unsigned long nrand(unsigned long n);
  876.  
  877. /* OpenDataFiles.c */
  878.  
  879. unsigned long OpenDataFiles(FILE **inPtr,FILE **outPtr
  880.                     ,char *inName,char *outName);
  881.  
  882. /* OpenPreferencesFolder.c */
  883.  
  884. #if !MAC_C
  885.     #define OSErr short
  886. #endif
  887. OSErr OpenPreferencesFolder(void);
  888. OSErr ClosePreferencesFolder(void);
  889. OSErr OpenPreferencesWD(short *wdRefNumPtr);
  890. #if !MAC_C
  891.     #undef OSErr
  892. #endif
  893.  
  894. #if MAC_C
  895.     /*    PixMapToPICT.c */
  896.  
  897.     void PixMapToPICT(char *filename,PixMap **pm,Rect *rectPtr
  898.         ,int pixelSize,ColorTable **cTable);
  899.  
  900.     /*    PixMapToPostScript.c */
  901.     
  902.     void WindowToEPS(CWindowPtr window,char *filename,Rect *rectPtr
  903.         ,Rect *pageRectPtr,double cellsPerInch,int grayLevels,float reflectance[256]);
  904.     void PixMapToEPS(char *filename,PixMap **pm,Rect *rectPtr
  905.         ,Rect *pageRectPtr,double cellsPerInch,int grayLevels);
  906.     void PixMapToPostScript(char *filename,PixMap **pm,Rect *rectPtr
  907.         ,Rect *pageRectPtr,double cellsPerInch,int grayLevels);
  908.     void AppendToFile(char *filename,char *string);
  909.     
  910.     /* PlotXY.c */
  911.     
  912.     typedef struct{
  913.         Boolean continuing;    /* zero to start a new curve */
  914.         long color;            /* e.g. blackColor, blueColor */
  915.         short lineWidth;    /* in pixels, zero for none */
  916.         short symbolWidth;    /* in pixels, zero for none */
  917.         short dashOffset;    /* in pixels */
  918.         short dash[5];        /* in pixels. The array is terminated by a zero element */
  919.         short h,v;            /* reserved for internal use */
  920.         Fixed pathLengthF;    /* reserved for internal use */
  921.     } PlotXYStyle;
  922.     void PlotXY(WindowPtr window,double x,double y,PlotXYStyle *style);
  923. #endif
  924.  
  925. /* PrintfExit.c */
  926.  
  927. int PrintfExit(const char *format,...);
  928.  
  929. #if MAC_C
  930.  
  931.     /* PrintfGWorld.c */
  932.  
  933.     void PrintfGWorld(GWorldPtr our);
  934.     void PrintStringAsBitmap(unsigned char *s);
  935.  
  936.     /* QD32Exists.c */
  937.     
  938.     Boolean         QD8Exists(void);
  939.     Boolean            QD32Exists(void);
  940.     Boolean            NewPaletteManager(void);
  941. #endif
  942.  
  943. /* randU.c */
  944.  
  945. unsigned short    randU(void);
  946. unsigned long    randUL(void);
  947. void            srandU(unsigned n);
  948. void            RandFill(void *address,long bytes);
  949.  
  950. /* ReadMATLABFile.c */
  951.  
  952. int LoadNamedMatIntoDoubles(FILE *f,const char *name,long *rows,long *cols
  953.     ,double **real,double **imag);
  954. int LoadNamedMatIntoShorts(FILE *f,const char *name,long *rows,long *cols
  955.     ,short **real,short **imag);
  956. int LoadNextMatIntoDoubles(FILE *f,char *name,long *rows,long *cols
  957.     ,double **real,double **imag);
  958. int LoadNextMatIntoShorts(FILE *f,char *name,long *rows,long *cols
  959.     ,short **real,short **imag);
  960. int SaveMatDoubles(FILE *f,char *name,long rows,long cols,double *real,double *imag);
  961. int SaveMatShorts(FILE *f,char *name,long rows,long cols,short *real,short *imag);
  962.  
  963. #if MAC_C
  964.     /* RectToAddress.c */
  965.     
  966.     unsigned char *RectToAddress(PixMap *pixMapPtr,Rect *rectPtr,short *rowBytesPtr, 
  967.         short *pixelSizePtr,short *bitsOffsetPtr);
  968.     Ptr GetPixBaseAddr32(PixMap **pm);
  969. #endif
  970.     
  971. /*    Require.c    */
  972.  
  973. void Require(long quickDrawVersion);
  974. struct PrecompileSizeofInt{
  975.     int i;
  976. };
  977. struct PrecompileSizeofDouble{
  978.     double d;
  979. };
  980.  
  981. #if MAC_C
  982.     /* RestoreCluts.c */
  983.     
  984.     void RestoreCluts(void);
  985.     
  986.     /*    SetEntriesQuickly.c */
  987.     
  988.     OSErr SetEntriesQuickly(GDHandle device,short start,short count,ColorSpec *table);
  989.     short macltset(GDHandle device,register short start
  990.         ,unsigned short *red,unsigned short *green,unsigned short *blue,short count1);
  991.     short GetCardType(GDHandle device);
  992.     char *GetCardBase(GDHandle device);
  993.     OSErr WaitForNextBlanking(GDHandle device);
  994.     
  995.     /* SetFileInfo.c */
  996.     
  997.     void    SetFileInfo(char *fileName,OSType fileType,OSType fileCreator);
  998.     
  999.     /* SetMouse.c */
  1000.     
  1001.     void    SetMouse(Point where);
  1002.     
  1003.     /* SetOnePixel.c */
  1004.     
  1005.     void SetPixmapPixel(PixMap *pmHandle,int x,int y,unsigned long value);
  1006.     unsigned long GetPixmapPixel(PixMap *pmHandle,int x,int y);
  1007.     unsigned char *GetPixmapPixelAddress(PixMap *pmHandle,int x,int y);
  1008.     void SetDevicePixel(GDHandle device,int x,int y,unsigned long value);
  1009.     unsigned long GetDevicePixel(GDHandle device,int x,int y);
  1010.     void SetOnePixel(int x,int y,unsigned long value);
  1011.     unsigned long GetOnePixel(int x,int y);
  1012.     #define SetIPixel SetDevicePixel    /*  So that old programs won't break. */
  1013.     #define GetIPixel GetDevicePixel    /*  So that old programs won't break. */
  1014.     
  1015.     /* SetPixelsQuickly.c */
  1016.     
  1017.     int SetPixelsQuickly(int x,int y,unsigned long value[],short n);
  1018.     int GetPixelsQuickly(int x,int y,unsigned long value[],short n);
  1019.     int SetWindowPixelsQuickly(WindowPtr window,int x,int y,unsigned long value[],short n);
  1020.     int GetWindowPixelsQuickly(WindowPtr window,int x,int y,unsigned long value[],short n);
  1021.     int SetDevicePixelsQuickly(GDHandle device,int x,int y,unsigned long value[],short n);
  1022.     int GetDevicePixelsQuickly(GDHandle device,int x,int y,unsigned long value[],short n);
  1023.     int SetPixmapPixelsQuickly(PixMapPtr pmPtr,int x,int y,unsigned long value[],short n);
  1024.     int GetPixmapPixelsQuickly(PixMapPtr pmPtr,int x,int y,unsigned long value[],short n);
  1025.     
  1026.     /* SetPriority.c */
  1027.     
  1028.     void SwapPriority(char *priority);
  1029.     void SetPriority(int i);
  1030.     int GetPriority(void);
  1031. #endif
  1032.  
  1033. /* Shuffle.c */
  1034.  
  1035. void Shuffle(void *array,long elements,size_t elementSize);
  1036.  
  1037. #if MAC_C
  1038.     /* SndPlay1.c */
  1039.     
  1040.     OSErr SndPlay1(Handle snd);
  1041.     void SndStop1(void);
  1042.     short SndDone1(void);
  1043.  
  1044.     /* StringToDateAndSecs.c */
  1045.     
  1046.     double StringToDateAndSecs(char *string,DateTimeRec *date);
  1047.  
  1048.     /* StringBounds.c */
  1049.     
  1050.     void CharBounds(char a,Rect *bounds,long *count);
  1051.     void StringBounds(const unsigned char *s,Rect *bounds,long *count);
  1052.     void StrBounds(char *s,Rect *bounds,long *count);
  1053.  
  1054.     /* Timer.c */
  1055.     
  1056.     struct Timer{
  1057.         TMTask time;
  1058.         long ourA5;
  1059.         long interval,elapsed,elapsedIntervals;
  1060.         long timeToStartTimer;            /*  minimum time in µs */
  1061.         long stopDelay;                    /*  µs from call to stop, re from call to start */
  1062.         long timeManagerVersion;
  1063.         struct Timer *next,*previous;    /*  doubly linked list of Timers */
  1064.     };
  1065.     typedef struct Timer Timer;
  1066.     
  1067.     Timer *NewTimer(void);
  1068.     void DisposeTimer(Timer *t);
  1069.     void StartTimer(Timer *t);
  1070.     long StopTimer(Timer *t);                    /*  µs */
  1071.     double StopTimerSecs(Timer *t);                /*  s */
  1072.     long PeekTimer(Timer *t);                    /*  µs */
  1073.     double PeekTimerSecs(Timer *t);                /*  s */
  1074.     
  1075.     /* TitleBarHeight.c */
  1076.     
  1077.     int TitleBarHeight(WindowPtr window);
  1078.     
  1079.     /* TrapAvailable.c */
  1080.     
  1081.     Boolean    TrapAvailable(short theTrap);
  1082. #endif
  1083.  
  1084. /* Uniform.c */
  1085.  
  1086. double UniformSample(void);
  1087.  
  1088. #if MAC_C
  1089.     /* VBLInstall.c */
  1090.     
  1091.     struct VBLTaskAndA5 {
  1092.         volatile VBLTask vbl;
  1093.         long ourA5;
  1094.         #if USESROUTINEDESCRIPTORS
  1095.             UniversalProcPtr subroutine;
  1096.         #else
  1097.             void (*subroutine)(struct VBLTaskAndA5 *vblData);
  1098.         #endif
  1099.         GDHandle device;
  1100.         long slot;
  1101.         volatile long newFrame;        /*  Boolean */
  1102.         volatile long frame;        // count up from zero
  1103.         volatile long framesLeft;    /*  count down to zero */
  1104.         long framesDesired;
  1105.         Timer *frameTimer;            /*  time ms since last VBL interrupt, see Timer.c */
  1106.         void *ptr;                    /*  use this for whatever you want */
  1107.     };
  1108.     typedef struct VBLTaskAndA5 VBLTaskAndA5;    
  1109.     OSErr VBLInstall(VBLTaskAndA5 *vblData,GDHandle device,long frames);
  1110.     OSErr VBLRemove(VBLTaskAndA5 *vblData);
  1111.     void SimpleVBLSubroutine(VBLTaskAndA5 *vblData);
  1112.     
  1113.     /* VideoTFB.c */
  1114.     
  1115.     Boolean TFBInSlot(int slot);
  1116.     void    SetUpTFB(int slot);
  1117.     void    RampClutTFB(int slot);
  1118.     void    GrayClutTFB(int slot);
  1119.     void    LoadClutTFB(int slot,unsigned char rgb[256][3]);
  1120.     void    NewBlankingTFB(int slot);
  1121.     void    NewFieldTFB(int slot);
  1122.     int        BlankingTFB(int slot);
  1123.     void    SetDepthTFB(int slot,short int bits);
  1124.     void    SynchSetDepthTFB(int masterSlot,int slot,short int bits);
  1125.     void    SynchToMainDeviceTFB(GDHandle device);
  1126.     void    HaltTFB(int slot);
  1127.     void    RestartTFB(int slot,short int bits);
  1128.     void    HaltDeviceTFB(GDHandle device);
  1129.     void    RestartDeviceTFB(GDHandle device);
  1130.     void    ScrollTFB(int slot,short int bits,long x,long y);
  1131.     void    PanTFB(int slot,long int x);
  1132. #endif
  1133.  
  1134. /* VLambda.c */
  1135.  
  1136. double VLambda(double nm);
  1137. double VLambdaPrime(double nm);
  1138.  
  1139. #if MAC_C
  1140.     /* Zoom.c */
  1141.     
  1142.     void Zoom(WindowPtr theWindow,int zoomDir,EventRecord *event);
  1143. #endif
  1144.  
  1145. #endif /* _VIDEOTOOLBOX_ */
  1146.